{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# CPSC 330 Python notes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### About this document\n",
    "\n",
    "This document contains some Python lecture materials from the 1st offering of CPSC 330. I have decided to stop allocated lecture time to this topic and instead have this as reference material."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Plotting with matplotlib"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- We will use [matplotlib](https://matplotlib.org/) as our plotting library.\n",
    "- For those familiar with MATLAB, this package is based on MATLAB plotting.\n",
    "- To use matplotlib, we first import it:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- We can now use functions in `plt` to plot things:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x7fbe2619e110>]"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjMsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+AADFEAAAeAElEQVR4nO3deXhU5fn/8fctIPsqYZGAATc2RUIEFOteRVS0VhGE1loqBaGulS/W1lat9Vdt1aoVa9XLKrv7brUi1bpnYUcQ2UVI2NdASO7fHzO0ERNykkzmzEw+r+vi4mTOSebj8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FjA3R8F3iByF8JSYBdwVXTfJjO7E/g8+qPu8G+/xKrpXLcRWQd7JHJ9g30e6aTWlsjLLogM8Cnu/lYcc10KjDGzfcBuYKhHRs8+MxsH/JPI3QhPuvuCOOYC+AHwtrvvLPWtNXq+gAHAj4B50XVOgF8RKZZhjrEgucIYY0FyhTHGguSC+I+x9sA/zKwOkdWPGe7+mpndAWS7+yvAE8AzZraUyC+bodHMC8xsBrAQ2AeM9cjyTaXorf8iIiki2dbQRUSkHCroIiIpQgVdRCRFqKCLiKQIFXQRkRShgi4ikiJU0EVEUsT/B9seqwclqTLrAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "x = [1,2,3]\n",
    "y = [4,4,5]\n",
    "plt.plot(x,y)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- You will often see me put a semicolon at the end of a line. \n",
    "- This is only relevant to Jupyter; it suppresses the line of \"output\".."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAeAElEQVR4nO3deXhU5fn/8fctIPsqYZGAATc2RUIEFOteRVS0VhGE1loqBaGulS/W1lat9Vdt1aoVa9XLKrv7brUi1bpnYUcQ2UVI2NdASO7fHzO0ERNykkzmzEw+r+vi4mTOSebj8eHOM885c4+5OyIikvwOCTuAiIjEhgq6iEiKUEEXEUkRKugiIilCBV1EJEXUDeuJW7du7RkZGWE9vYhIUsrJydng7mll7QutoGdkZJCdnR3W04uIJCU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PI3QhPuvuCOOYC+AHwtrvvLPWtNXq+gAHAj4B50XVOgF8RKZZhjrEgucIYY0FyhTHGguSC+I+x9sA/zKwOkdWPGe7+mpndAWS7+yvAE8AzZraUyC+bodHMC8xsBrAQ2AeM9cjyTaXorf8iIiki2dbQRUSkHCroIiIpQgVdRCRFqKCLiKQIFXQRkRShgi4ikiJU0EVEUsT/B9seqwclqTLrAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x,y);"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- The [homework instructions document](https://github.students.cs.ubc.ca/cpsc330-2019w-t2/home/blob/master/docs/homework_instructions.md#figures) includes a section on figures.\n",
    "- At a minimum, you should have axis labels for _every_ figure out submit."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3dd5wV9fX/8dcBkSJdEJTiAiIIKLJsAMWeWILGFjskxhj9iRJb1OjXfI2xxG/UGL82jIl+LRTFGuwdNSgqu3QQRLoovddl9/z+mNl4XbfMws6du3vfz8fjPu7cqWeH4Z4785k5H3N3REQke9VJOgAREUmWEoGISJZTIhARyXJKBCIiWU6JQEQky+2WdABV1apVK8/JyUk6DBGRGiU/P3+lu7cua1qNSwQ5OTlMnDgx6TBERGoUM1tY3jRdGhIRyXJKBCIiWU6JQEQkyykRiIhkOSUCEZEsF2siMLMFZjbNzCab2Q9u9bHAfWY218ymmllunPGIiMgPpeP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2bTdi4bWUCbpg2456zeKiZXy0StNfRLM1sUfu5I0H3lNMDd/aDYohORxBUXO1c+ExSTe27oITRvpGJytU2URHBC7FGISMa6/725fDBnBbef1ouD2quYXG1UaWOxuy8EOgDHhMObgDruvjD8LCK11AdzVnDvu3M4vU87zuunYnK1VZSic38Efg/cEI7aHRgRZ1Aikryv127hyqcnsf9eTbj9NBWTq82i3D56GnAywZkA7r6U4BkAEamltu8o5rKRBRQWOcOH5NJw97pJhyQxipIItru7812toT3iDUlEknb7qzOZvHgtd55xEJ1VTK7Wi5IIxpjZ34HmZnYR8A7wj3jDEpGkjJ2ylCc+WciFh3Vi0IEqJpcNotQautvMjgXWE9Qbusnd3449MhFJuy+XbeD656eSt28Lrv9p96TDkTSJ1ItE+MWvL3+RWmzTth0MHVlAo93r8sB5udSrq2Jy2aLcRGBmGwjbBcri7k1jiUhE0s7duf6FacxbsZERF/anbbMGSYckaVRuInD3JvCf2kDfEhSaM2AwumtIpFZ58pOFvDxlKdce341D91MxuWwT5dzveHd/yN03uPt6dx8O/DzuwEQkPQoWreG2V2fy4+57MfTILkmHIwmIkgiKzGxw2Al9HTMbTNX6LBaRDLV603aGjSygbbMG3HPWwSoml6WiJILzgLOAZeHrzHCciNRgRcXOFU9PYuWm7Qwf3JdmjeolHZIkJMrtowuAU+IPRUTS6X/f/ZKPvlzJHacfSK92zZIORxKk+8NEstC42cu5/70v+Xlue875UYekw5GEKRGIZJklazZz5TOT6damCbed2kvF5ESJQCSbbNtRxGUjCygqcoYP6aticgJEK0PdxsweNbPXw889zOzC+EMTkep22yuzmLJkHXedeRCdWql+pASinBE8DrwJ7BN+ngNcGVdAIhKPf03+mqcmLOSiwztxQi8Vk5PvREkErdx9DFAM4O470HMEIjXKnGUbuP75afwopwXXnaBicvJ9URLBJjPbk+/6IxgArIs1KhGpNhu37eCSEfnsUX83FZOTMkWpPno1MBboYmbjgdbAGbFGJSLVwt35/fNTWbByEyN/M4A2TVVMTn4oygNlBWZ2JEFfBAbM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gR66BKdf/G5lZ6i/ms1PeS37VvgUMK5kh/KVd2bZPC9spmhDUsceDOvfzzezMcD1mKf0Fl6Oyffc0QTG7wwmKskFQKfOb8OziFwRnVpVpBiwPk8DRwL4p0zqW/JsQ9ND171LLVrZPpQZSIpBq5UG9+/EWdPx9VwXzbSeoQPkXM5sCTCa4lLIzhhM0SE8FrgM+C7exAvgVMDqcNgHonrJcfTP7FLiC4Jc1BJdC8sLG0pnAJRVt2IOuD58J43+eoIRwicHAheHfN4PKu1ycSlB9c0rpxuLQWwSXwd4J9x/AQ8D5ZjaB4LJQeWcBqUYS/I0Twxi/SJk2K1zfVIIS2sNTF4ywT6UGUvVRyUrh5ZA8d1+ZdCwiSdMZgYhIltMZgYhIltMZgYhIllMiEBHJckoEIiJZTolARCTLKRGIiGS5/w/mSeuRv05VFQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x,y)\n",
    "plt.xlabel(\"the independent variable\")\n",
    "plt.ylabel(\"the dependent variable\");"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- If you are plotting multiple curves, make sure you include a legend!"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAEGCAYAAABo25JHAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjEsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy8QZhcZAAAgAElEQVR4nO3deXwV9bn48c+ThYQlYUsgSAj7HlwwIpsKKLJI4ddX7a9ad21prVbR2mqrV1t7F3vbe3vr9VZ/3Oqtttaltl6iNYiK+wKCVQkJq2yBhBCWQAgJWZ7fH98JHGKW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DoR+QjXLNTYVUCop3F/4xovxg0h8/K99X2OK6H9aOgHfexT0wFZ9VETlbzmkCxVLQk6FmOCZlcExhgT5eyKwBhjopxdERhjTJSzRGCMMVHOEoExxkQ5SwTGGBPlLBEYY0yU+/8bD18YS8LHJwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.plot(x,y, label=\"label is y\")\n",
    "plt.plot(x,x, label=\"x\")\n",
    "plt.xlabel(\"the independent variable\")\n",
    "plt.ylabel(\"the dependent variables\")\n",
    "plt.legend();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- You will likely need to visit the [matplotlib.pyplot documentation](https://matplotlib.org/api/pyplot_api.html) when trying to do other things.\n",
    "- When you save an `.ipynb` file, the output, including plots, is stored in the file.\n",
    "  - This is a hassle for git.\n",
    "  - But it's also convenient.\n",
    "  - This is how you will submit plots."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Numpy arrays\n",
    "\n",
    "Basic numpy is covered in the posted videos, you are expected to have a basic knowledge of numpy."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([0., 0., 0., 0.])"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x = np.zeros(4)\n",
    "x"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "y = np.ones(4)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([1., 1., 1., 1.])"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "x+y"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.32951575, 0.02235815, 0.46370585],\n",
       "       [0.49948886, 0.50463463, 0.28996511]])"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z = np.random.rand(2,3)\n",
    "z"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.022358151559601525"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "z[0,1]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Numpy array shapes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**One of the most confusing things about numpy:** what I call a \"1-D array\" can have 3 possible shapes:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[1. 1. 1. 1. 1.]\n",
      "size: 5\n",
      "ndim: 1\n",
      "shape: (5,)\n"
     ]
    }
   ],
   "source": [
    "x = np.ones(5)\n",
    "print(x)\n",
    "print(\"size:\", x.size)\n",
    "print(\"ndim:\", x.ndim)\n",
    "print(\"shape:\",x.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1. 1. 1. 1. 1.]]\n",
      "size: 5\n",
      "ndim: 2\n",
      "shape: (1, 5)\n"
     ]
    }
   ],
   "source": [
    "y = np.ones((1,5))\n",
    "print(y)\n",
    "print(\"size:\", y.size)\n",
    "print(\"ndim:\", y.ndim)\n",
    "print(\"shape:\",y.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[[1.]\n",
      " [1.]\n",
      " [1.]\n",
      " [1.]\n",
      " [1.]]\n",
      "size: 5\n",
      "ndim: 2\n",
      "shape: (5, 1)\n"
     ]
    }
   ],
   "source": [
    "z = np.ones((5,1))\n",
    "print(z)\n",
    "print(\"size:\", z.size)\n",
    "print(\"ndim:\", z.ndim)\n",
    "print(\"shape:\",z.shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array_equal(x,y)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array_equal(x,z)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "False"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.array_equal(y,z)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Broadcasting in numpy\n",
    "\n",
    "- Arrays with different sizes cannot be directly used in arithmetic operations.\n",
    "- Broadcasting describes how numpy treats arrays with different shapes during arithmetic operations.\n",
    "- The idea is to **vectorize** operations to avoid loops and speed up the code."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- Example: I sell pies on the weekends.\n",
    "- I sell 3 types of pies at different prices, and I sold the following number of each pie last weekend.\n",
    "- I want to know how much money I made per pie type per day."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<img src='img/pies.png' width=\"500\"> "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Pie cost:\n",
      "[[20]\n",
      " [15]\n",
      " [25]]\n",
      "\n",
      "Pie sales (#):\n",
      "[[2 3 1]\n",
      " [6 3 3]\n",
      " [5 3 5]]\n"
     ]
    }
   ],
   "source": [
    "cost = np.array([20, 15, 25])\n",
    "print(\"Pie cost:\")\n",
    "print(cost.reshape(3,1))\n",
    "sales = np.array([[2, 3, 1],\n",
    "                  [6, 3, 3],\n",
    "                  [5, 3, 5]])\n",
    "print(\"\\nPie sales (#):\")\n",
    "print(sales)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- How can we multiply these two arrays together?\n",
    "\n",
    "<img src='img/pies_loop.png' width=\"500\"> "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Slowest method: nested loop\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 40.,  60.,  20.],\n",
       "       [ 90.,  45.,  45.],\n",
       "       [125.,  75., 125.]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total = np.zeros((3, 3))\n",
    "for i in range(3):\n",
    "    for j in range(3):\n",
    "        total[i,j] = cost[i] * sales[i,j]\n",
    "total"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Faster method: vectorize the loop over rows"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 40.,  60.,  20.],\n",
       "       [ 90.,  45.,  45.],\n",
       "       [125.,  75., 125.]])"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "total = np.zeros((3, 3))\n",
    "for j in range(3):\n",
    "    total[:,j] = cost * sales[:,j]\n",
    "total"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### No-loop method: make them the same size, and multiply element-wise\n",
    "\n",
    "\n",
    "<img src='img/pies_broadcast.png' width=\"700\"> \n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[20, 20, 20],\n",
       "       [15, 15, 15],\n",
       "       [25, 25, 25]])"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cost_rep = np.repeat(cost[:,np.newaxis], 3, axis=1)\n",
    "cost_rep"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 40,  60,  20],\n",
       "       [ 90,  45,  45],\n",
       "       [125,  75, 125]])"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cost_rep * sales"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- What is `np.newaxis?`\n",
    "- It changes the shape:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3,)"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cost.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3, 1)"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cost[:,np.newaxis].shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3, 1)"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cost.reshape(3,1).shape # the name thing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 3)"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cost[np.newaxis].shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Fastest method: broadcasting"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 40,  60,  20],\n",
       "       [ 90,  45,  45],\n",
       "       [125,  75, 125]])"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "cost[:,np.newaxis] * sales"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- numpy does the equivalent of `np.repeat()` for you - no need to do it explicitly\n",
    "- It is debatable whether this code is more readable, but it is definitely faster. "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### When can we use broadcasting?"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Say we want to broadcast the following two arrays:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "arr1 = np.arange(3)\n",
    "arr2 = np.ones((5))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0],\n",
       "       [1],\n",
       "       [2]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 1., 1., 1., 1.]])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3,)"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(5,)"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr2.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- The broadcast will fail because the arrays are not compatible..."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "operands could not be broadcast together with shapes (3,) (5,) ",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-26-d972d21b639e>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0marr1\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0marr2\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m: operands could not be broadcast together with shapes (3,) (5,) "
     ]
    }
   ],
   "source": [
    "arr1 + arr2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- We can facilitate this broadcast by adding a dimension using `np.newaxis`.\n",
    "- `np.newaxis` increases the dimension of an array by one dimension."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3,)"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "arr1 = arr1[:, np.newaxis]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3, 1)"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [],
   "source": [
    "arr2 = arr2[np.newaxis]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 5)"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr2.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[1., 1., 1., 1., 1.],\n",
       "       [2., 2., 2., 2., 2.],\n",
       "       [3., 3., 3., 3., 3.]])"
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1 + arr2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- the opposite, reducing a dimension, can be achieved by `np.squeeze()`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3, 1)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "arr1.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(3,)"
      ]
     },
     "execution_count": 36,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.squeeze(arr1).shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The rules of broadcasting:\n",
    "\n",
    "- NumPy compares arrays one dimension at a time. It starts with the trailing dimensions, and works its way to the first dimensions.\n",
    "- dimensions are compatible if:\n",
    "    - **they are equal**, or\n",
    "    - **one of them is 1**.\n",
    "- Use the code below to test out array compatibitlity"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The shape of a is: (5, 1)\n",
      "The shape of b is: (1, 3)\n",
      "The shape of a + b is: (5, 3)\n"
     ]
    }
   ],
   "source": [
    "a = np.ones((5,1))\n",
    "b = np.ones((1,3))\n",
    "print(f\"The shape of a is: {a.shape}\")\n",
    "print(f\"The shape of b is: {b.shape}\")\n",
    "try:\n",
    "    print(f\"The shape of a + b is: {(a + b).shape}\")\n",
    "except:\n",
    "    print(f\"ERROR: arrays are NOT broadcast compatible!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "toc-hr-collapsed": false
   },
   "source": [
    "## Introduction to pandas"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- The most popular Python library for tabular data structures"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pandas Series\n",
    "- A Series is like a NumPy array but with labels\n",
    "- 1-dimensional\n",
    "- Can be created from a list, ndarray or dictionary using `pd.Series()`\n",
    "- Labels may be integers or strings"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Here are two series of gold medal counts for the 2012 and 2016 Olympics:\n",
    "\n",
    "<img src='img/series.png' width=\"400\"> "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 42,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Series([], dtype: float64)"
      ]
     },
     "execution_count": 42,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.Series()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "USA    46\n",
       "CHN    38\n",
       "GBR    29\n",
       "RUS    19\n",
       "GER    17\n",
       "dtype: int64"
      ]
     },
     "execution_count": 43,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 = pd.Series(data = [46, 38, 29, 19, 17],\n",
    "               index = ['USA','CHN','GBR','RUS','GER'])\n",
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "USA    46\n",
       "CHN    26\n",
       "GBR    27\n",
       "dtype: int64"
      ]
     },
     "execution_count": 44,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2 = pd.Series([46, 26, 27],\n",
    "               ['USA', 'CHN', 'GBR'])\n",
    "s2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- Like ndarrays we use square brackets `[]` to index a series\n",
    "- BUT, Series can be indexed by an integer location **OR** a label"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "USA    46\n",
       "CHN    38\n",
       "GBR    29\n",
       "RUS    19\n",
       "GER    17\n",
       "dtype: int64"
      ]
     },
     "execution_count": 45,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "46"
      ]
     },
     "execution_count": 46,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.iloc[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 47,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38"
      ]
     },
     "execution_count": 47,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.iloc[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "46"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1[\"USA\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "USA    46\n",
       "CHN    38\n",
       "GBR    29\n",
       "RUS    19\n",
       "dtype: int64"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1[\"USA\":\"RUS\"]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Do we expect these two series to be compatible for broadcasting?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "USA    46\n",
       "CHN    38\n",
       "GBR    29\n",
       "RUS    19\n",
       "GER    17\n",
       "dtype: int64"
      ]
     },
     "execution_count": 50,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "USA    46\n",
       "CHN    26\n",
       "GBR    27\n",
       "dtype: int64"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The shape of s1 is: (5,)\n",
      "The shape of s2 is: (3,)\n"
     ]
    }
   ],
   "source": [
    "print(f\"The shape of s1 is: {s1.shape}\")\n",
    "print(f\"The shape of s2 is: {s2.shape}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "CHN    64.0\n",
       "GBR    56.0\n",
       "GER     NaN\n",
       "RUS     NaN\n",
       "USA    92.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 + s2"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- Unlike ndarrays operations between Series (+, -, /, \\*) align values based on their **LABELS**\n",
    "- The result index will be the __*sorted union*__ of the two indexes"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Pandas DataFrames\n",
    "\n",
    "- The primary Pandas data structure\n",
    "- Really just a bunch of Series (with the same index labels) stuck together\n",
    "- Made using `pd.DataFrame()`\n",
    "\n",
    "<img src='img/dataframe.png' width=\"600\"> "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Creating a DataFrame with a numpy array"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2012</th>\n",
       "      <th>2016</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>USA</th>\n",
       "      <td>46</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CHN</th>\n",
       "      <td>38</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GBR</th>\n",
       "      <td>29</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2012  2016\n",
       "USA    46    46\n",
       "CHN    38    26\n",
       "GBR    29    27"
      ]
     },
     "execution_count": 54,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d = np.array([[46, 46],\n",
    "              [38, 26],\n",
    "              [29, 27]])\n",
    "c = ['2012', '2016']\n",
    "i = ['USA', 'CHN', 'GBR']\n",
    "df = pd.DataFrame(data=d, index=i, columns=c)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(optional) Creating a DataFrame with a dictionary"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2012</th>\n",
       "      <th>2016</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>USA</th>\n",
       "      <td>46</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CHN</th>\n",
       "      <td>38</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GBR</th>\n",
       "      <td>29</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2012  2016\n",
       "USA    46    46\n",
       "CHN    38    26\n",
       "GBR    29    27"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "d = {'2012': [46, 38, 29],\n",
    "     '2016': [46, 26, 27]}\n",
    "i = ['USA', 'CHN', 'GBR']\n",
    "df = pd.DataFrame(d, i)\n",
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Indexing Dataframes\n",
    "- There are three main ways to index a DataFrame:\n",
    "    1. `[]` (slice for rows, label for columns)\n",
    "    2. `.loc[]`\n",
    "    3. `.iloc[]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 56,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2012</th>\n",
       "      <th>2016</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>USA</th>\n",
       "      <td>46</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CHN</th>\n",
       "      <td>38</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GBR</th>\n",
       "      <td>29</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2012  2016\n",
       "USA    46    46\n",
       "CHN    38    26\n",
       "GBR    29    27"
      ]
     },
     "execution_count": 56,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "##### `[]` notation\n",
    "- you can index columns by single labels or lists of labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "USA    46\n",
       "CHN    38\n",
       "GBR    29\n",
       "Name: 2012, dtype: int64"
      ]
     },
     "execution_count": 57,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['2012']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "pandas.core.series.Series"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(df['2012'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 61,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "list"
      ]
     },
     "execution_count": 61,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(['2012', '2016'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 59,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2012</th>\n",
       "      <th>2016</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>USA</th>\n",
       "      <td>46</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CHN</th>\n",
       "      <td>38</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GBR</th>\n",
       "      <td>29</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2012  2016\n",
       "USA    46    46\n",
       "CHN    38    26\n",
       "GBR    29    27"
      ]
     },
     "execution_count": 59,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['2012', '2016']]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(optional) you can also index rows with `[]`, but you can only index rows with slices"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 62,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2012</th>\n",
       "      <th>2016</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>CHN</th>\n",
       "      <td>38</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GBR</th>\n",
       "      <td>29</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2012  2016\n",
       "CHN    38    26\n",
       "GBR    29    27"
      ]
     },
     "execution_count": 62,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[\"CHN\":\"GBR\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 64,
   "metadata": {},
   "outputs": [],
   "source": [
    "# df[\"USA\"] # doesn't work"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 65,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2012</th>\n",
       "      <th>2016</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>USA</th>\n",
       "      <td>46</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2012  2016\n",
       "USA    46    46"
      ]
     },
     "execution_count": 65,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[:\"USA\"] # does work"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- this is a little unintuitive, so pandas created two other ways to index a dataframe:\n",
    "- for indexing with integers: `df.iloc[]`\n",
    "- for indexing with labels: `df.loc[]`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 66,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2012</th>\n",
       "      <th>2016</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>USA</th>\n",
       "      <td>46</td>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>CHN</th>\n",
       "      <td>38</td>\n",
       "      <td>26</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GBR</th>\n",
       "      <td>29</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2012  2016\n",
       "USA    46    46\n",
       "CHN    38    26\n",
       "GBR    29    27"
      ]
     },
     "execution_count": 66,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012    38\n",
       "2016    26\n",
       "Name: CHN, dtype: int64"
      ]
     },
     "execution_count": 67,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27"
      ]
     },
     "execution_count": 68,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.iloc[2,1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2012    38\n",
       "2016    26\n",
       "Name: CHN, dtype: int64"
      ]
     },
     "execution_count": 69,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc['CHN']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "27"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc['GBR', '2016']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>2012</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>USA</th>\n",
       "      <td>46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>GBR</th>\n",
       "      <td>29</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     2012\n",
       "USA    46\n",
       "GBR    29"
      ]
     },
     "execution_count": 71,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[['USA', 'GBR'], ['2012']]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['USA', 'CHN', 'GBR'], dtype='object')"
      ]
     },
     "execution_count": 72,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['2012', '2016'], dtype='object')"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 76,
   "metadata": {},
   "outputs": [],
   "source": [
    "#df.loc[df.index[0], '2016']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [],
   "source": [
    "#df.loc['USA', df.columns[0]]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Indexing cheatsheet\n",
    "- `[]` accepts slices for row indexing or labels (single or list) for column indexing\n",
    "- `.iloc[]` accepts integers for row/column indexing, and can be single values or lists\n",
    "- `.loc[]` accepts labels for row/column indexing, and can be single values or lists\n",
    "- for integer row/named column: `df.loc[df.index[#], 'labels']`\n",
    "- for named row/integer column: `df.loc['labels', df.columns[#]]`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Break (5 min)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Reading from .csv\n",
    "- Most of the time you will be loading .csv files for use in pandas using `pd.read_csv()`\n",
    "- Example dataset: a colleague's cycling commute to/from UBC everyday"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 78,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = 'data/cycling_data.csv'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>Date</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2019-09-10 00:13:04</th>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-09-10 13:52:18</th>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-09-11 00:23:50</th>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-09-11 14:06:19</th>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2019-09-12 00:28:05</th>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                               Name  Type  Time  Distance  \\\n",
       "Date                                                        \n",
       "2019-09-10 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "2019-09-10 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2019-09-11 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "2019-09-11 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "2019-09-12 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                                         Comments  \n",
       "Date                                               \n",
       "2019-09-10 00:13:04                          Rain  \n",
       "2019-09-10 13:52:18                          rain  \n",
       "2019-09-11 00:23:50     Wet road but nice weather  \n",
       "2019-09-11 14:06:19  Stopped for photo of sunrise  \n",
       "2019-09-12 00:28:05  Tired by the end of the week  "
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "pd.read_csv(path, index_col=0, parse_dates=True).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Reading from url\n",
    "- you may also want to read directly from an url at times\n",
    "- `pd.read_csv()` accepts urls as input"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 80,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Bottle</th>\n",
       "      <th>Grape</th>\n",
       "      <th>Origin</th>\n",
       "      <th>Alcohol</th>\n",
       "      <th>pH</th>\n",
       "      <th>Colour</th>\n",
       "      <th>Aroma</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Chardonnay</td>\n",
       "      <td>Australia</td>\n",
       "      <td>14.23</td>\n",
       "      <td>3.51</td>\n",
       "      <td>White</td>\n",
       "      <td>Floral</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>Pinot Grigio</td>\n",
       "      <td>Italy</td>\n",
       "      <td>13.20</td>\n",
       "      <td>3.30</td>\n",
       "      <td>White</td>\n",
       "      <td>Fruity</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>Pinot Blanc</td>\n",
       "      <td>France</td>\n",
       "      <td>13.16</td>\n",
       "      <td>3.16</td>\n",
       "      <td>White</td>\n",
       "      <td>Citrus</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>Shiraz</td>\n",
       "      <td>Chile</td>\n",
       "      <td>14.91</td>\n",
       "      <td>3.39</td>\n",
       "      <td>Red</td>\n",
       "      <td>Berry</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>Malbec</td>\n",
       "      <td>Argentina</td>\n",
       "      <td>13.83</td>\n",
       "      <td>3.28</td>\n",
       "      <td>Red</td>\n",
       "      <td>Fruity</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Bottle         Grape     Origin  Alcohol    pH Colour   Aroma\n",
       "0       1    Chardonnay  Australia    14.23  3.51  White  Floral\n",
       "1       2  Pinot Grigio      Italy    13.20  3.30  White  Fruity\n",
       "2       3   Pinot Blanc     France    13.16  3.16  White  Citrus\n",
       "3       4        Shiraz      Chile    14.91  3.39    Red   Berry\n",
       "4       5        Malbec  Argentina    13.83  3.28    Red  Fruity"
      ]
     },
     "execution_count": 80,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "url = 'https://raw.githubusercontent.com/TomasBeuzen/toy-datasets/master/wine_1.csv'\n",
    "pd.read_csv(url)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Reading from other formats\n",
    "\n",
    "- `pd.read_excel()`\n",
    "- `pd.read_html()`\n",
    "- `pd.read_json()`\n",
    "- etc"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Dataframe summaries"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 83,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 83,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('data/cycling_data.csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 84,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 33 entries, 0 to 32\n",
      "Data columns (total 6 columns):\n",
      "Date        33 non-null object\n",
      "Name        33 non-null object\n",
      "Type        33 non-null object\n",
      "Time        33 non-null int64\n",
      "Distance    31 non-null float64\n",
      "Comments    33 non-null object\n",
      "dtypes: float64(1), int64(1), object(4)\n",
      "memory usage: 1.7+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 85,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>33</td>\n",
       "      <td>33</td>\n",
       "      <td>33</td>\n",
       "      <td>33.000000</td>\n",
       "      <td>31.000000</td>\n",
       "      <td>33</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>unique</th>\n",
       "      <td>33</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>top</th>\n",
       "      <td>26 Sep 2019, 13:42:43</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>freq</th>\n",
       "      <td>1</td>\n",
       "      <td>17</td>\n",
       "      <td>33</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>3512.787879</td>\n",
       "      <td>12.667419</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>8003.309233</td>\n",
       "      <td>0.428618</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1712.000000</td>\n",
       "      <td>11.790000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>1863.000000</td>\n",
       "      <td>12.480000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2118.000000</td>\n",
       "      <td>12.620000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>2285.000000</td>\n",
       "      <td>12.750000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>NaN</td>\n",
       "      <td>48062.000000</td>\n",
       "      <td>14.570000</td>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                         Date            Name  Type          Time   Distance  \\\n",
       "count                      33              33    33     33.000000  31.000000   \n",
       "unique                     33               2     1           NaN        NaN   \n",
       "top     26 Sep 2019, 13:42:43  Afternoon Ride  Ride           NaN        NaN   \n",
       "freq                        1              17    33           NaN        NaN   \n",
       "mean                      NaN             NaN   NaN   3512.787879  12.667419   \n",
       "std                       NaN             NaN   NaN   8003.309233   0.428618   \n",
       "min                       NaN             NaN   NaN   1712.000000  11.790000   \n",
       "25%                       NaN             NaN   NaN   1863.000000  12.480000   \n",
       "50%                       NaN             NaN   NaN   2118.000000  12.620000   \n",
       "75%                       NaN             NaN   NaN   2285.000000  12.750000   \n",
       "max                       NaN             NaN   NaN  48062.000000  14.570000   \n",
       "\n",
       "            Comments  \n",
       "count             33  \n",
       "unique            25  \n",
       "top     Feeling good  \n",
       "freq               3  \n",
       "mean             NaN  \n",
       "std              NaN  \n",
       "min              NaN  \n",
       "25%              NaN  \n",
       "50%              NaN  \n",
       "75%              NaN  \n",
       "max              NaN  "
      ]
     },
     "execution_count": 85,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.describe(include='all')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Renaming columns with `df.rename()`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 86,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 86,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- we can rename specific columns using `df.rename()`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Comments': 'Notes'}"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "{\"Comments\": \"Notes\"}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "dict"
      ]
     },
     "execution_count": 88,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type({\"Comments\": \"Notes\"})"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 87,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Notes</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                          Notes  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 87,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.rename(columns={\"Comments\": \"Notes\"})\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- there are two options for making permanent dataframe changes:\n",
    "    - 1. set the argument `inplace=True`, e.g., `df.rename(..., inplace=True)`\n",
    "    - 2. re-assign, e.g., `df = df.rename(...)`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.rename(columns={\"Comments\": \"Notes\"}, inplace=True) # inplace\n",
    "df = df.rename(columns={\"Comments\": \"Notes\"}) # re-assign"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### NOTE:\n",
    "- the pandas team discourages the use of `inplace` for a [few reasons](https://www.youtube.com/watch?v=hK6o_TDXXN8&t=700)\n",
    "- mostly because not all functions have the argument, hides memory copying, leads to hard-to-find bugs\n",
    "- it is recommend to **re-assign** (method 2 above)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- we can also change all columns at once using a list"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>col1</th>\n",
       "      <th>col2</th>\n",
       "      <th>col3</th>\n",
       "      <th>col4</th>\n",
       "      <th>col5</th>\n",
       "      <th>col6</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    col1            col2  col3  col4   col5  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084  12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531  13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863  12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192  12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891  12.48   \n",
       "\n",
       "                           col6  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 90,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns = ['col1', 'col2', 'col3', 'col4', 'col5', 'col6']\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Adding/removing columns with `[]` and `drop()`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 91,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('data/cycling_data.csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- adding a single column"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "      <th>Speed</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "      <td>3.141593</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "      <td>3.141593</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "      <td>3.141593</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "      <td>3.141593</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "      <td>3.141593</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments     Speed  \n",
       "0                          Rain  3.141593  \n",
       "1                          rain  3.141593  \n",
       "2     Wet road but nice weather  3.141593  \n",
       "3  Stopped for photo of sunrise  3.141593  \n",
       "4  Tired by the end of the week  3.141593  "
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df['Speed'] = 3.14159265358979323\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- dropping a column"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.drop(columns=\"Speed\")\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- we can also add/drop multiple columns at a time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 95,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.drop(columns=['Type', 'Time'])\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Adding/removing rows with `[]` and `drop()`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 96,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>4 Oct 2019, 01:08:08</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1870</td>\n",
       "      <td>12.63</td>\n",
       "      <td>Very tired, riding into the wind</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>9 Oct 2019, 13:55:40</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2149</td>\n",
       "      <td>12.70</td>\n",
       "      <td>Really cold! But feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>10 Oct 2019, 00:10:31</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1841</td>\n",
       "      <td>12.59</td>\n",
       "      <td>Feeling good after a holiday break!</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>10 Oct 2019, 13:47:14</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2463</td>\n",
       "      <td>12.79</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type  Time  Distance  \\\n",
       "28   4 Oct 2019, 01:08:08  Afternoon Ride  Ride  1870     12.63   \n",
       "29   9 Oct 2019, 13:55:40    Morning Ride  Ride  2149     12.70   \n",
       "30  10 Oct 2019, 00:10:31  Afternoon Ride  Ride  1841     12.59   \n",
       "31  10 Oct 2019, 13:47:14    Morning Ride  Ride  2463     12.79   \n",
       "32  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "\n",
       "                                     Comments  \n",
       "28           Very tired, riding into the wind  \n",
       "29              Really cold! But feeling good  \n",
       "30        Feeling good after a holiday break!  \n",
       "31               Stopped for photo of sunrise  \n",
       "32  Bike feeling tight, needs an oil and pump  "
      ]
     },
     "execution_count": 96,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('data/cycling_data.csv')\n",
    "df.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 97,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Date                            11 Oct 2019, 00:16:57\n",
       "Name                                   Afternoon Ride\n",
       "Type                                             Ride\n",
       "Time                                             1843\n",
       "Distance                                        11.79\n",
       "Comments    Bike feeling tight, needs an oil and pump\n",
       "Name: 32, dtype: object"
      ]
     },
     "execution_count": 97,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "last_row = df.iloc[-1]\n",
    "last_row"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(optional) We can add the row to the end of the dataframe using `df.append()`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 98,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>9 Oct 2019, 13:55:40</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2149</td>\n",
       "      <td>12.70</td>\n",
       "      <td>Really cold! But feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>10 Oct 2019, 00:10:31</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1841</td>\n",
       "      <td>12.59</td>\n",
       "      <td>Feeling good after a holiday break!</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>10 Oct 2019, 13:47:14</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2463</td>\n",
       "      <td>12.79</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type  Time  Distance  \\\n",
       "29   9 Oct 2019, 13:55:40    Morning Ride  Ride  2149     12.70   \n",
       "30  10 Oct 2019, 00:10:31  Afternoon Ride  Ride  1841     12.59   \n",
       "31  10 Oct 2019, 13:47:14    Morning Ride  Ride  2463     12.79   \n",
       "32  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "32  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "\n",
       "                                     Comments  \n",
       "29              Really cold! But feeling good  \n",
       "30        Feeling good after a holiday break!  \n",
       "31               Stopped for photo of sunrise  \n",
       "32  Bike feeling tight, needs an oil and pump  \n",
       "32  Bike feeling tight, needs an oil and pump  "
      ]
     },
     "execution_count": 98,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.append(last_row)\n",
    "df.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 99,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(34, 6)"
      ]
     },
     "execution_count": 99,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- but now we have the index label `32` occurring twice (that can be bad! Why?)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type  Time  Distance  \\\n",
       "32  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "32  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "\n",
       "                                     Comments  \n",
       "32  Bike feeling tight, needs an oil and pump  \n",
       "32  Bike feeling tight, needs an oil and pump  "
      ]
     },
     "execution_count": 100,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.loc[32]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>4 Oct 2019, 01:08:08</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1870</td>\n",
       "      <td>12.63</td>\n",
       "      <td>Very tired, riding into the wind</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>9 Oct 2019, 13:55:40</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2149</td>\n",
       "      <td>12.70</td>\n",
       "      <td>Really cold! But feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>10 Oct 2019, 00:10:31</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1841</td>\n",
       "      <td>12.59</td>\n",
       "      <td>Feeling good after a holiday break!</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>10 Oct 2019, 13:47:14</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2463</td>\n",
       "      <td>12.79</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type  Time  Distance  \\\n",
       "28   4 Oct 2019, 01:08:08  Afternoon Ride  Ride  1870     12.63   \n",
       "29   9 Oct 2019, 13:55:40    Morning Ride  Ride  2149     12.70   \n",
       "30  10 Oct 2019, 00:10:31  Afternoon Ride  Ride  1841     12.59   \n",
       "31  10 Oct 2019, 13:47:14    Morning Ride  Ride  2463     12.79   \n",
       "32  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "\n",
       "                                     Comments  \n",
       "28           Very tired, riding into the wind  \n",
       "29              Really cold! But feeling good  \n",
       "30        Feeling good after a holiday break!  \n",
       "31               Stopped for photo of sunrise  \n",
       "32  Bike feeling tight, needs an oil and pump  "
      ]
     },
     "execution_count": 101,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.iloc[0:33]\n",
    "df.tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- we need can set `ignore_index=True` to avoid duplicate index labels"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 102,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>9 Oct 2019, 13:55:40</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2149</td>\n",
       "      <td>12.70</td>\n",
       "      <td>Really cold! But feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>10 Oct 2019, 00:10:31</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1841</td>\n",
       "      <td>12.59</td>\n",
       "      <td>Feeling good after a holiday break!</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>10 Oct 2019, 13:47:14</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2463</td>\n",
       "      <td>12.79</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type  Time  Distance  \\\n",
       "29   9 Oct 2019, 13:55:40    Morning Ride  Ride  2149     12.70   \n",
       "30  10 Oct 2019, 00:10:31  Afternoon Ride  Ride  1841     12.59   \n",
       "31  10 Oct 2019, 13:47:14    Morning Ride  Ride  2463     12.79   \n",
       "32  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "33  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "\n",
       "                                     Comments  \n",
       "29              Really cold! But feeling good  \n",
       "30        Feeling good after a holiday break!  \n",
       "31               Stopped for photo of sunrise  \n",
       "32  Bike feeling tight, needs an oil and pump  \n",
       "33  Bike feeling tight, needs an oil and pump  "
      ]
     },
     "execution_count": 102,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.append(last_row, ignore_index=True)\n",
    "df.tail()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>4 Oct 2019, 01:08:08</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1870</td>\n",
       "      <td>12.63</td>\n",
       "      <td>Very tired, riding into the wind</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>9 Oct 2019, 13:55:40</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2149</td>\n",
       "      <td>12.70</td>\n",
       "      <td>Really cold! But feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>10 Oct 2019, 00:10:31</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1841</td>\n",
       "      <td>12.59</td>\n",
       "      <td>Feeling good after a holiday break!</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>10 Oct 2019, 13:47:14</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2463</td>\n",
       "      <td>12.79</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>11 Oct 2019, 00:16:57</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1843</td>\n",
       "      <td>11.79</td>\n",
       "      <td>Bike feeling tight, needs an oil and pump</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type  Time  Distance  \\\n",
       "28   4 Oct 2019, 01:08:08  Afternoon Ride  Ride  1870     12.63   \n",
       "29   9 Oct 2019, 13:55:40    Morning Ride  Ride  2149     12.70   \n",
       "30  10 Oct 2019, 00:10:31  Afternoon Ride  Ride  1841     12.59   \n",
       "31  10 Oct 2019, 13:47:14    Morning Ride  Ride  2463     12.79   \n",
       "32  11 Oct 2019, 00:16:57  Afternoon Ride  Ride  1843     11.79   \n",
       "\n",
       "                                     Comments  \n",
       "28           Very tired, riding into the wind  \n",
       "29              Really cold! But feeling good  \n",
       "30        Feeling good after a holiday break!  \n",
       "31               Stopped for photo of sunrise  \n",
       "32  Bike feeling tight, needs an oil and pump  "
      ]
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = df.drop(index=[33])\n",
    "df.tail()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Sorting a dataframe with `df.sort_values()`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('data/cycling_data.csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>27 Sep 2019, 01:00:18</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1712</td>\n",
       "      <td>12.47</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>3 Oct 2019, 00:45:22</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1724</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>1 Oct 2019, 00:15:07</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1732</td>\n",
       "      <td>NaN</td>\n",
       "      <td>Legs feeling strong!</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2 Oct 2019, 00:13:09</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1756</td>\n",
       "      <td>NaN</td>\n",
       "      <td>A little tired today but good weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>25 Sep 2019, 00:07:21</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1775</td>\n",
       "      <td>12.10</td>\n",
       "      <td>Feeling really tired</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type  Time  Distance  \\\n",
       "20  27 Sep 2019, 01:00:18  Afternoon Ride  Ride  1712     12.47   \n",
       "26   3 Oct 2019, 00:45:22  Afternoon Ride  Ride  1724     12.52   \n",
       "22   1 Oct 2019, 00:15:07  Afternoon Ride  Ride  1732       NaN   \n",
       "24   2 Oct 2019, 00:13:09  Afternoon Ride  Ride  1756       NaN   \n",
       "16  25 Sep 2019, 00:07:21  Afternoon Ride  Ride  1775     12.10   \n",
       "\n",
       "                                 Comments  \n",
       "20           Tired by the end of the week  \n",
       "26                           Feeling good  \n",
       "22                   Legs feeling strong!  \n",
       "24  A little tired today but good weather  \n",
       "16                   Feeling really tired  "
      ]
     },
     "execution_count": 105,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_values(by='Time').head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 106,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 106,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- use the `ascending` argument to specify sort order as ascending or descending"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>19 Sep 2019, 00:30:01</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>48062</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20 Sep 2019, 01:02:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2961</td>\n",
       "      <td>12.81</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>18 Sep 2019, 13:49:53</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2903</td>\n",
       "      <td>14.57</td>\n",
       "      <td>Raining today</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>10 Oct 2019, 13:47:14</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2463</td>\n",
       "      <td>12.79</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type   Time  Distance  \\\n",
       "10  19 Sep 2019, 00:30:01  Afternoon Ride  Ride  48062     12.48   \n",
       "12  20 Sep 2019, 01:02:05  Afternoon Ride  Ride   2961     12.81   \n",
       "8   18 Sep 2019, 13:49:53    Morning Ride  Ride   2903     14.57   \n",
       "1   10 Sep 2019, 13:52:18    Morning Ride  Ride   2531     13.03   \n",
       "31  10 Oct 2019, 13:47:14    Morning Ride  Ride   2463     12.79   \n",
       "\n",
       "                        Comments  \n",
       "10                  Feeling good  \n",
       "12                  Feeling good  \n",
       "8                  Raining today  \n",
       "1                           rain  \n",
       "31  Stopped for photo of sunrise  "
      ]
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_values(by=\"Time\", ascending=False).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "(optional) we can sort by multiple columns in succession by passing in lists"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>19 Sep 2019, 00:30:01</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>48062</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20 Sep 2019, 01:02:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2961</td>\n",
       "      <td>12.81</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>18 Sep 2019, 00:15:52</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2101</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Pumped up tires</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>24 Sep 2019, 00:35:42</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2076</td>\n",
       "      <td>12.47</td>\n",
       "      <td>Oiled chain, bike feels smooth</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type   Time  Distance  \\\n",
       "10  19 Sep 2019, 00:30:01  Afternoon Ride  Ride  48062     12.48   \n",
       "12  20 Sep 2019, 01:02:05  Afternoon Ride  Ride   2961     12.81   \n",
       "9   18 Sep 2019, 00:15:52  Afternoon Ride  Ride   2101     12.48   \n",
       "0   10 Sep 2019, 00:13:04  Afternoon Ride  Ride   2084     12.62   \n",
       "14  24 Sep 2019, 00:35:42  Afternoon Ride  Ride   2076     12.47   \n",
       "\n",
       "                          Comments  \n",
       "10                    Feeling good  \n",
       "12                    Feeling good  \n",
       "9                  Pumped up tires  \n",
       "0                             Rain  \n",
       "14  Oiled chain, bike feels smooth  "
      ]
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_values(by=['Name', 'Time'], ascending=[True, False]).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- we can sort a dataframe back to it's orginal state (based on index) using `df.sort_index()`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sort_index().head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Filtering a dataframe with `[]` and `df.query()`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- we've already seen how to filter a dataframe using `[]`, `.loc` and `.iloc` notation\n",
    "- but what if we want more control?\n",
    "- `df.query()` is a powerful tool for filtering data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('data/cycling_data.csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- `df.query()` accepts a string expression to evaluate, using it's own syntax"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>19 Sep 2019, 00:30:01</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>48062</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20 Sep 2019, 01:02:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2961</td>\n",
       "      <td>12.81</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type   Time  Distance      Comments\n",
       "10  19 Sep 2019, 00:30:01  Afternoon Ride  Ride  48062     12.48  Feeling good\n",
       "12  20 Sep 2019, 01:02:05  Afternoon Ride  Ride   2961     12.81  Feeling good"
      ]
     },
     "execution_count": 112,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.query('Time > 2500 and Distance < 13')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>19 Sep 2019, 00:30:01</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>48062</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20 Sep 2019, 01:02:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2961</td>\n",
       "      <td>12.81</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type   Time  Distance      Comments\n",
       "10  19 Sep 2019, 00:30:01  Afternoon Ride  Ride  48062     12.48  Feeling good\n",
       "12  20 Sep 2019, 01:02:05  Afternoon Ride  Ride   2961     12.81  Feeling good"
      ]
     },
     "execution_count": 113,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[(df['Time'] > 2500) & (df['Distance'] < 13)]"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- we can refer to variables in the environment by prefixing them with an `@` "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>18 Sep 2019, 13:49:53</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2903</td>\n",
       "      <td>14.57</td>\n",
       "      <td>Raining today</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>19 Sep 2019, 00:30:01</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>48062</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>20 Sep 2019, 01:02:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2961</td>\n",
       "      <td>12.81</td>\n",
       "      <td>Feeling good</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                     Date            Name  Type   Time  Distance  \\\n",
       "8   18 Sep 2019, 13:49:53    Morning Ride  Ride   2903     14.57   \n",
       "10  19 Sep 2019, 00:30:01  Afternoon Ride  Ride  48062     12.48   \n",
       "12  20 Sep 2019, 01:02:05  Afternoon Ride  Ride   2961     12.81   \n",
       "\n",
       "         Comments  \n",
       "8   Raining today  \n",
       "10   Feeling good  \n",
       "12   Feeling good  "
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "thresh = 2800\n",
    "df.query('Time > @thresh')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Applying functions to a dataframe with `df.apply()` and `df.applymap()`"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- many common functions are built into Pandas as dataframe methods\n",
    "- e.g., `df.mean()`, `df.round()`, `df.min()`, `df.max()`, `df.sum()`, etc."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Date</th>\n",
       "      <th>Name</th>\n",
       "      <th>Type</th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "      <th>Comments</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10 Sep 2019, 00:13:04</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "      <td>Rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>10 Sep 2019, 13:52:18</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "      <td>rain</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>11 Sep 2019, 00:23:50</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "      <td>Wet road but nice weather</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>11 Sep 2019, 14:06:19</td>\n",
       "      <td>Morning Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "      <td>Stopped for photo of sunrise</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>12 Sep 2019, 00:28:05</td>\n",
       "      <td>Afternoon Ride</td>\n",
       "      <td>Ride</td>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "      <td>Tired by the end of the week</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                    Date            Name  Type  Time  Distance  \\\n",
       "0  10 Sep 2019, 00:13:04  Afternoon Ride  Ride  2084     12.62   \n",
       "1  10 Sep 2019, 13:52:18    Morning Ride  Ride  2531     13.03   \n",
       "2  11 Sep 2019, 00:23:50  Afternoon Ride  Ride  1863     12.52   \n",
       "3  11 Sep 2019, 14:06:19    Morning Ride  Ride  2192     12.84   \n",
       "4  12 Sep 2019, 00:28:05  Afternoon Ride  Ride  1891     12.48   \n",
       "\n",
       "                       Comments  \n",
       "0                          Rain  \n",
       "1                          rain  \n",
       "2     Wet road but nice weather  \n",
       "3  Stopped for photo of sunrise  \n",
       "4  Tired by the end of the week  "
      ]
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df = pd.read_csv('data/cycling_data.csv')\n",
    "df.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 117,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Time        3512.787879\n",
       "Distance      12.667419\n",
       "dtype: float64"
      ]
     },
     "execution_count": 117,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.mean()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 118,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Date                         1 Oct 2019, 00:15:07\n",
       "Name                               Afternoon Ride\n",
       "Type                                         Ride\n",
       "Time                                         1712\n",
       "Distance                                    11.79\n",
       "Comments    A little tired today but good weather\n",
       "dtype: object"
      ]
     },
     "execution_count": 118,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.min()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Date        9 Oct 2019, 13:55:40\n",
       "Name                Morning Ride\n",
       "Type                        Ride\n",
       "Time                       48062\n",
       "Distance                   14.57\n",
       "Comments                 raining\n",
       "dtype: object"
      ]
     },
     "execution_count": 119,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.max()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Date        10 Sep 2019, 00:13:0410 Sep 2019, 13:52:1811 S...\n",
       "Name        Afternoon RideMorning RideAfternoon RideMornin...\n",
       "Type        RideRideRideRideRideRideRideRideRideRideRideRi...\n",
       "Time                                                   115922\n",
       "Distance                                               392.69\n",
       "Comments    RainrainWet road but nice weatherStopped for p...\n",
       "dtype: object"
      ]
     },
     "execution_count": 120,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sum()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- however there will be times when you want to apply a non-built in function\n",
    "- `df.apply()` applies a function column-wise or row-wise\n",
    "- the function must be able to operate over an entire row or column at a time"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2084</td>\n",
       "      <td>12.62</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2531</td>\n",
       "      <td>13.03</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1863</td>\n",
       "      <td>12.52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2192</td>\n",
       "      <td>12.84</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1891</td>\n",
       "      <td>12.48</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Time  Distance\n",
       "0  2084     12.62\n",
       "1  2531     13.03\n",
       "2  1863     12.52\n",
       "3  2192     12.84\n",
       "4  1891     12.48"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['Time', 'Distance']].head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.9092974268256817"
      ]
     },
     "execution_count": 122,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sin(2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 124,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 124,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.sin(0)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- you may use functions from other packages, such as numpy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 125,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Time</th>\n",
       "      <th>Distance</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>-0.901866</td>\n",
       "      <td>0.053604</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>-0.901697</td>\n",
       "      <td>0.447197</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.035549</td>\n",
       "      <td>-0.046354</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>-0.739059</td>\n",
       "      <td>0.270228</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>-0.236515</td>\n",
       "      <td>-0.086263</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "       Time  Distance\n",
       "0 -0.901866  0.053604\n",
       "1 -0.901697  0.447197\n",
       "2 -0.035549 -0.046354\n",
       "3 -0.739059  0.270228\n",
       "4 -0.236515 -0.086263"
      ]
     },
     "execution_count": 125,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['Time', 'Distance']].apply(np.sin).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- or make your own custom function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 126,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>34.733333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>42.183333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>31.050000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>36.533333</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>31.516667</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        Time\n",
       "0  34.733333\n",
       "1  42.183333\n",
       "2  31.050000\n",
       "3  36.533333\n",
       "4  31.516667"
      ]
     },
     "execution_count": 126,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df[['Time']].apply(lambda x: x/60).head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- use `df.applymap()` for functions that accept and return a scalar"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 127,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 33 entries, 0 to 32\n",
      "Data columns (total 6 columns):\n",
      "Date        33 non-null object\n",
      "Name        33 non-null object\n",
      "Type        33 non-null object\n",
      "Time        33 non-null int64\n",
      "Distance    31 non-null float64\n",
      "Comments    33 non-null object\n",
      "dtypes: float64(1), int64(1), object(4)\n",
      "memory usage: 1.7+ KB\n"
     ]
    }
   ],
   "source": [
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 128,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "3.0"
      ]
     },
     "execution_count": 128,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "float(3)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 129,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "float() argument must be a string or a number, not 'list'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-129-7c9875858560>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# this function only accepts a single value, so this will fail\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m: float() argument must be a string or a number, not 'list'"
     ]
    }
   ],
   "source": [
    "float([1, 2]) # this function only accepts a single value, so this will fail"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 130,
   "metadata": {},
   "outputs": [
    {
     "ename": "TypeError",
     "evalue": "(\"cannot convert the series to <class 'float'>\", 'occurred at index Time')",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mTypeError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-130-4550bed00aba>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mdf\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'Time'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhead\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# fails\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/core/frame.py\u001b[0m in \u001b[0;36mapply\u001b[0;34m(self, func, axis, broadcast, raw, reduce, result_type, args, **kwds)\u001b[0m\n\u001b[1;32m   6926\u001b[0m             \u001b[0mkwds\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   6927\u001b[0m         )\n\u001b[0;32m-> 6928\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mop\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mget_result\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m   6929\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m   6930\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mapplymap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36mget_result\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    184\u001b[0m             \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_raw\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    185\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 186\u001b[0;31m         \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_standard\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    187\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    188\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mapply_empty_result\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36mapply_standard\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    290\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    291\u001b[0m         \u001b[0;31m# compute the result using the series generator\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 292\u001b[0;31m         \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapply_series_generator\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    293\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    294\u001b[0m         \u001b[0;31m# wrap results\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/core/apply.py\u001b[0m in \u001b[0;36mapply_series_generator\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    319\u001b[0m             \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    320\u001b[0m                 \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mv\u001b[0m \u001b[0;32min\u001b[0m \u001b[0menumerate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mseries_gen\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 321\u001b[0;31m                     \u001b[0mresults\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    322\u001b[0m                     \u001b[0mkeys\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mappend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mv\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    323\u001b[0m             \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    129\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    130\u001b[0m             \u001b[0;32mreturn\u001b[0m \u001b[0mconverter\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0miloc\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 131\u001b[0;31m         \u001b[0;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"cannot convert the series to \"\u001b[0m \u001b[0;34m\"{0}\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mconverter\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    132\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    133\u001b[0m     \u001b[0mwrapper\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"__{name}__\"\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mname\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mconverter\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__name__\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mTypeError\u001b[0m: (\"cannot convert the series to <class 'float'>\", 'occurred at index Time')"
     ]
    }
   ],
   "source": [
    "df[['Time']].apply(float).head() # fails"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 131,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2084.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2531.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1863.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2192.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1891.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     Time\n",
       "0  2084.0\n",
       "1  2531.0\n",
       "2  1863.0\n",
       "3  2192.0\n",
       "4  1891.0"
      ]
     },
     "execution_count": 131,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_float_1 = df[['Time']].applymap(float).head() # works with applymap\n",
    "df_float_1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "- however, if you're applying an in-built function, there's often another (vectorized) way...\n",
    "- from [Pandas docs](https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.applymap.html) \"*Note that a vectorized version of func often exists, which will be much faster.*\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 132,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2084.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2531.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>1863.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2192.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>1891.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     Time\n",
       "0  2084.0\n",
       "1  2531.0\n",
       "2  1863.0\n",
       "3  2192.0\n",
       "4  1891.0"
      ]
     },
     "execution_count": 132,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_float_2 = df[['Time']].astype(float).head() # alternatively, use astype\n",
    "df_float_2"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 133,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "948 µs ± 37.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "# using vectorized .astype\n",
    "%timeit df[['Time']].astype(float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 134,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.53 ms ± 85.7 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
     ]
    }
   ],
   "source": [
    "# using element-wise .applymap\n",
    "%timeit df[['Time']].applymap(float)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
